package com.hzhq.contract.convert;

import com.hzhq.contract.bean.dto.UserRoleDTO;
import com.hzhq.contract.bean.entity.UserRole;
import com.hzhq.contract.bean.vo.UserRoleVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

/**
 * @Author: hzhq1255
 * @Mail: hzhq1255@163.com
 * @Date: 2021/5/3 20:16
 * @Desc:
 */
@Mapper
public interface UserRoleConvertBasic {

    UserRoleConvertBasic INSTANCE = Mappers.getMapper(UserRoleConvertBasic.class);


    UserRoleDTO poToDto(UserRole source);

    UserRole dtoToPo(UserRoleDTO source);


    @Mappings({
            @Mapping(target = "user", expression = "java(source.getUser().getUsername())"),
            @Mapping(target = "role", expression = "java(source.getRole().getRoleName())"),
            @Mapping(target = "admin", expression = "java(source.getAdmin().getAdminName())")
    })
    UserRoleVO dtoToVo(UserRoleDTO source);


}
